<template>
  <div class="home">
    <el-card class="welcome-card">
      <template #header>
        <div class="card-header">
          <span>欢迎使用用户登录系统</span>
        </div>
      </template>

      <div v-if="!isLoggedIn" class="login-prompt">
        <p>请先登录以访问完整功能</p>
        <div class="button-group">
          <el-button type="primary" @click="$router.push('/login')">
            登录
          </el-button>
          <el-button @click="$router.push('/register')">
            注册
          </el-button>
        </div>
      </div>

      <div v-else class="user-info">
        <p>您已成功登录！</p>
        <el-button type="success" @click="$router.push('/profile')">
          查看个人资料
        </el-button>
      </div>
    </el-card>
  </div>
</template>

<script>
export default {
  name: 'Home',
  computed: {
    isLoggedIn () {
      return !!localStorage.getItem('token')
    }
  }
}
</script>

<style scoped>
.home {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 60vh;
}

.welcome-card {
  width: 400px;
  text-align: center;
}

.card-header {
  font-size: 18px;
  font-weight: bold;
}

.login-prompt, .user-info {
  padding: 20px 0;
}

.button-group {
  margin-top: 20px;
}

.button-group .el-button {
  margin: 0 10px;
}
</style>
